package com.project.psc.controller;

import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.project.psc.bean.GoodsBean;
import com.project.psc.bean.SupplyBean;
import com.project.psc.dto.SupplierDto;
import com.project.psc.service.ISupplyService;
import com.project.psc.util.SupplierThreadLocal;
import com.project.psc.vo.AddSupplyVo;
import com.project.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("supply")
public class SupplyController {
    @Autowired
    private ISupplyService supplyService;

    @RequestMapping("updateStatus")
    public  Boolean updateStatus(@RequestParam("batch") String batch, @RequestParam("status")Integer status) {

         supplyService.updateStatus(batch, status);
         return true;
    }

    @PostMapping("addSupply")
    public ResultVo addSupply(@RequestBody AddSupplyVo addSupplyVo) {
        SupplierDto loginUser = SupplierThreadLocal.getSupplier();
        supplyService.addSupply(addSupplyVo, loginUser.getId(), loginUser.getSupplierName());
        return ResultVo.ok();
    }
}
